package com.sync.hkmjsyncdata.config.isecurecenter;


import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Service
public class IsecureCenterUtilsService {

    //OpenAPI接口的上下文
    static final String ARTEMIS_PATH = "artemis";
    //参数提交方式
    static final String CONTENT_TYPE = "application/json";

    @Resource
    IsecureCenterParams centerParams;










    /**
     * 封装监控请求
     *
     * @return ;
     */
    public synchronized String doPost(String requestUrl, String params) {
        JSONObject resultInfo=new JSONObject();
        //设置平台参数
        ArtemisConfig.host = centerParams.getHost()+":"+centerParams.getPort(); // artemis网关服务器ip端口
        ArtemisConfig.appKey = centerParams.getAppKey();  // 密钥appkey
        ArtemisConfig.appSecret = centerParams.getAppSecret();// 密钥appSecret
        //设置接口的URI地址
        final String previewURLsApi = "/" + ARTEMIS_PATH + requestUrl;
        Map<String, String> path = new HashMap<>();
        path.put("https://", previewURLsApi);
        return ArtemisHttpUtil.doPostStringArtemis(path, params, null, null,
                CONTENT_TYPE, null);
    }





}
